package com.wjqy.Interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AdminLoginInterceptor implements HandlerInterceptor {

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object admin = request.getSession().getAttribute("admin");
        if (admin!=null){
            return true;
        }else {
            response.setCharacterEncoding("utf-8");
            response.setHeader("contentType", "text/html; charset=utf-8");
            response.getWriter().write("please login");
            return false;
        }
    }

}
